package com.apchernykh.rozhlasapp.player;

import com.apchernykh.rozhlasapp.ui.RozhlasAppBaseFragmentActivity;
import com.apchernykh.types.DetailedUrl;
import com.apchernykh.types.ApplicationModel.EPlaybackStatuses;

import android.content.Context;
import android.os.AsyncTask;

public class TestPlayerWrapper implements IPlayerWrapper {
	final Context mContext;
	final IPlaybackCallbacks mParent;

	public TestPlayerWrapper(IPlaybackCallbacks iService) {
		mContext = (Context) iService;
		mParent = iService;
	}

	@Override
	public void stop() {
		// TODO Auto-generated method stub

	}

	@Override
	public boolean isActive() {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public int getCurrentPosition() {
		// TODO Auto-generated method stub
		return 0;
	}


	@Override
	public String play(DetailedUrl iUrl, int iSeekTo) {
		AsyncTask<Integer, Integer, Boolean> aTask = new AsyncTask<Integer, Integer, Boolean>(){

			@Override
			protected Boolean doInBackground(Integer... params) {
				try {
					//Test sequence - prebuffer, play, and stop
					mParent.onPlaybackStatusChanged(EPlaybackStatuses.CONNECTION_IN_PROGRESS);
					Thread.sleep(20000);
					mParent.onPlaybackStatusChanged(EPlaybackStatuses.PLAYING);
					Thread.sleep(200000);
					mParent.onPlaybackStatusChanged(EPlaybackStatuses.STOPPED);
				} catch (InterruptedException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				return null;
			}
			
		};
		if(RozhlasAppBaseFragmentActivity.mApplicationModel.mInetInfo.isDownloadAllowed())
		{
			aTask.execute(0);
		}		return null;
	}

	@Override
	public void pause() {
		// TODO Auto-generated method stub
		
	}

}